Initial Operations

# Clear the variables
rm(list = ls())

# Install packages
packages <- c("matlib", "rmarkdown", "tinytex","plotly")
new.packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if (length(new.packages)) install.packages(new.packages)
invisible(lapply(packages, library, character.only = TRUE))
# Load packages
library(matlib)
library(scatterplot3d)
library(plotly)
library(rgl)
options(digits = 15) 

POINT 2

We define a bisection alghorithm that max the value function which represents the following preferences: risk premium rate > 4% and risk free rate -> Epsilon

Risk computation

the risk computation function take m as input and compute the risk free / premium rate and recall the value function with such values.

The Value function

The value function represents the preferences given the risk premium rate = ‘dummy’ and ‘x’ = risk-free rate as input returns a higher value when x -> 1 and dummy > 4. The symmetric hyperbolic gives the function that evaluates the proximity to 1 of the risk-free rate function: \[ y=\frac{1}{|1-x|} \] While a dummy variable represents the risk-premium rate condition: \[ f(n) = \begin{cases} 1, & \mbox{if } risk premium\mbox{ <5\%} \\ 2, & \mbox{otherwise } \end{cases} \] Finally, the value function can be represented as: \[ g(n) = ln(\frac{1}{|1-x|}*f(n)) \]

Bisection alghorithm

Main function